<?php
namespace Modules\Frontend\Controllers;

class SwipeController extends \Phalcon\Mvc\Controller {
	public function beforeExecuteRoute() {
		\Components\Utils::isClosedFrontent($this);
	}

	public function initialize() {
		$this -> response -> setStatusCode(200, 'OK') -> sendHeaders() -> setContentType('application/json', 'UTF-8');
	}

	public function homeAction() {
		$service = $this -> swipe::getServiceInstance() -> find([
			'columns' => 'title,image',
			'conditions' => 'status = 0',
			'order' => 'swipe_id DESC'
		]);
		if($service['code'] != 0) {
			return $this -> response -> setJsonContent(['code'=>0,'msg'=>'Success','models' => []]);
		}

		return $this -> response -> setJsonContent(['code'=>0,'msg'=>'Success','models' => $service['models']]);
	}
}